package com.itcaius.weblog.web.convert;

import com.itcaius.weblog.common.domain.dos.ArticleDO;
import com.itcaius.weblog.web.model.vo.archive.FindArchiveArticlePageListReqVO;
import com.itcaius.weblog.web.model.vo.archive.FindArchiveArticleRspVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author Caius
 * @description
 * @since Created in 2025-05-01
 */
@Mapper
public interface ArchiveConvert {

    // 获取 ArchiveConvert 实例
    ArchiveConvert INSTANCE = Mappers.getMapper(ArchiveConvert.class);

    /**
     * 将 DO 转化为归档文章 VO
     * @param bean
     * @return
     */
    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    @Mapping(target = "createMonth", expression = "java(java.time.YearMonth.from(bean.getCreateTime()))")
    FindArchiveArticleRspVO convertDO2ArchiveArticleVO(ArticleDO bean);
}
